package com.chuhe.starry.controller;

import com.chuhe.common.domain.vo.req.LoginReq;
import com.chuhe.common.domain.vo.req.RegisterReq;
import com.chuhe.common.domain.vo.resp.ApiResult;
import com.chuhe.common.domain.vo.resp.LoginResp;
import com.chuhe.common.domain.vo.resp.SysSettingResp;
import com.chuhe.common.utils.RedisComponet;
import com.chuhe.starry.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;

/**
 * @Author: 楚河
 * @Date: 2025年05月10日22:28
 */
@RestController
@RequestMapping("/account")
@Validated
@Api(value = "用户信息接口", tags = "用户信息相关API", description = "用户信息API")
public class AccountController {
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private RedisComponet redisComponet;

    @ApiOperation("生成图片验证码")
    @RequestMapping("/checkCode")
    public ApiResult<?> checkCode(){
        return ApiResult.success(userInfoService.makeCheckCode());
    }

    @ApiOperation("用户注册")
    @RequestMapping("/register")
    public ApiResult<?> register(@Valid RegisterReq registerReq){
        return ApiResult.success(userInfoService.register(registerReq));
    }

    @ApiOperation("用户登录")
    @RequestMapping("/login")
    public ApiResult<LoginResp> login(@Valid LoginReq loginReq){
        return ApiResult.success(userInfoService.login(loginReq));
    }

    @ApiOperation("获取设置")
    @RequestMapping("/getSysSetting")
    public ApiResult<SysSettingResp> getSysSetting(){
        return ApiResult.success(redisComponet.getSysSetting());
    }

}
